<template lang="pug">
  .page
    .lzw-section
      .tab-title
        .font-14(v-for="(item,index) in filterNav" :key="index" @click="filterMethod(index,$event)" :data-status="item.status" :class="tabIndex === index ? 'active' : ''") {{item.txt}}
      .tab-container.pt-20
        .handle-box.clearfix.pr-20
          .pull-right
            template(v-if="tabIndex === 0")
              Button.mybtn-2(type="info" @click="create").ml-15 新建用户账号
            template(v-else)
              Button.mybtn-2(type="info" @click="create").ml-15 新建企业账号
            Button.mybtn-2(type="info" @click="cancel").ml-15 删除账号
        Table(border width="100%" stripe :columns="thead" :data="listData" height="500" :loading="loading" @on-selection-change="tableSelectChange")
          template(slot-scope="{ row, index }" slot="feedback")
            Rate(show-text allow-half disabled v-model="row.feedback")
              span(style="color:#f5a623") {{row.feedback}}
        div(style="margin: 10px;overflow: hidden")
          div(style="float: right;")
            Page(:total="totalcount" :current="pageIndex" :page-size="pageSize" @on-change="pageChange" show-total)
    createModal(ref="createModal")
</template>

<script>
import enterpriseMixin from './accountMixin.js'
import createModal from './modal/create.vue'
import checkModal from './modal/check.vue'

export default {
  name: 'v_account',
  components: {
    createModal,
    checkModal
  },
  data () {
    return {
      tabIndex: 0,
      filterNav: [
        {
          txt: '用户账号',
          status: '1'
        },
        {
          txt: '企业账号',
          status: '2'
        }
      ],
      thead: [],
      listData: [
        {
          enjoy_date: '2019年8月1日',
          name: '张三',
          sub_name: '人力产业园门店',
          identityCardNO: '403325199610081219',
          sex: '432432424',
          age: '18',
          edu: '本科',
          address: '长沙天心区',
          work_year: 3,
          work_experience: '肯德基',
          apply_time: '2019年8月1日',
          dispatch_order: '10656546',
          accept_order: '34324',
          finish_order: '56',
          fail_order: '2432423',
          ongoing_order: '3342',
          income: '瑞幸咖啡',
          feedback: 4.5,
          status: '人力产业园店'
        }
      ],
      ids: [],
      loading: false,
      totalcount: 0,
      pageIndex: 10,
      pageSize: 1,
      createModal: false
    }
  },
  mixins: [enterpriseMixin],
  created () {
    this.filterMethod(0)
  },
  methods: {
    filterMethod (index) {
      // let thead_extend = ['selection','enjoy_date','name','identityCardNO','sex','age','edu','address','work_year','work_experience','apply_time','dispatch_order','accept_order','finish_order','fail_order','ongoing_order','income','feedback','status']
      this.tabIndex = index
      if (index) {
        let thead_extend = ['selection', 'finish_order', 'fail_order', 'ongoing_order', 'income', 'status']
        this.thead = this.getTableColumns(thead_extend)
      } else {
        let thead_extend = ['selection', 'name', 'identityCardNO', 'dispatch_order', 'accept_order']
        this.thead = this.getTableColumns(thead_extend)
      }
    },
    tableSelectChange (val) {
      console.log(val)
      this.ids = val
    },
    pageChange (index) {
      this.pageIndex = index
    },
    checkInfo () {
      console.log()
    },
    create () {
      this.$refs.createModal.modalOpen()
    },
    cancel () {
      if (this.ids.length > 0) {
        this.$Message.success('成功')
      } else {
        this.$Message.warning('请选择需要删除的企业')
      }
    }
  }

}
</script>

<style lang="less">

</style>
